package test;

import java.util.Arrays;
import java.util.Iterator;
import java.util.Random;

public class MaxMin {
	public static void main(String[] args) {
		Random rand = new Random();
		// 产生5个随机数，把他们放入一个int数组中
		int[] array = rand.ints(5).toArray();
		System.out.println(Arrays.toString(array));
		
		int max = array[0],min = array[0];
		// TIP：遍历数组中的每个值和max比较，比max大就给max赋值
		for (int i = 0; i < array.length; i++) {
			if (max < array[i]) {
				max = array[i];
			}
			if (min > array[i]) {
				min = array[i];
			}
		}
		
		System.out.println(max);
		System.out.println(min);
	}
}
